package com.aaa.dang.modules.checkin.controller;

import ch.qos.logback.core.net.SyslogOutputStream;
import ch.qos.logback.core.util.FileUtil;
import com.aaa.dang.common.entity.Room;
import com.aaa.dang.common.util.BaseContrllor;
import com.aaa.dang.common.util.ResultModel;
import com.aaa.dang.common.util.UploadUtil;
import com.aaa.dang.modules.checkin.service.ICheckIn;
import com.sun.javafx.collections.MappingChange;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.transform.Result;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 刘旭泽
 * @version 1.0
 * @date 2018/12/14
 * @description
 */
@Controller
@RequestMapping("/checkin")
public class CheckIn extends BaseContrllor {

    @Autowired
    private ICheckIn service;

    @Autowired
    ServletContext sc;
    /**
     * @return String
     * @description 跳转到入住管理页面
     * @param[]
     * @author 刘旭泽
     * @date 2018/12/14
     **/
    @RequestMapping("/tocheckin")
    public String toCheckIn() {
        return "checkin/checkin";

    }

    /**
     * @return  com.aaa.dang.common.util.ResultModel
     * @description 获取页面展示的所有信息（空床信息）用于学生选择房间入住
     * @param[]
     * @author 刘旭泽
     * @date 2018/12/14
     **/
    @RequestMapping("/getAllMsg")
    @ResponseBody
    public ResultModel getAllMsg(@RequestParam Map<String, Object> query) {
        ResultModel mod = service.getAllMsg(query);
        return mod;
    }
    /**
     *@description  得到相应房间所有的空床位编号 用于办理入住选择床位下拉框动态展示
     *@return
     *@param
     *@author 刘旭泽
     *@date 2018/12/17
     **/
    @RequestMapping("/getEmptyBed")
    @ResponseBody
    public List<Map<String,Object>> getEmptyBed(@RequestParam Map<String, Object> query){
        List<Map<String,Object>> list = service.getEmptyBed(query);
        return list;

    }
    /**
     *@description  添加入住信息
     *@return com.aaa.dang.common.util.ResultModel
     *@param
     *@author 刘旭泽
     *@date 2018/12/17
     **/
    @RequestMapping("/addStuUser")
    @ResponseBody
    public ResultModel addStuUser(@RequestParam Map<String, Object> query){
        ResultModel mod = service.addStuUser(query);
        return mod;
    }

    /**
     *@description 入住办理输入手机号 ，input框失焦事件 发送请求 返回用户信息
     *@return java.util.Map<java.lang.String,java.lang.Object>
     *@param
     *@author 刘旭泽
     *@date 2018/12/19
     **/
    @RequestMapping("/checkPhone")
    @ResponseBody
    public ResultModel checkPhone(@RequestParam Map<String,Object> query){
        ResultModel mod = service.checkPhone(query);
        return mod;
    }

    @RequestMapping("/uploadExcel")
    @ResponseBody
    public ResultModel uploadExcel(@RequestParam("file") MultipartFile file,HttpServletRequest request){
        ResultModel mod = service.uploadExcel(file,request);
        return mod;


    }



}
